#ifndef _LIST_H
#define _LIST_H


struct list_t {
	struct list_t *next, *prev;
	void* payload;
};

struct list_iterator_t {
	struct list_t* head;
	struct list_t* curr;
	int first;
};

struct list_iterator_t list_get_iterator(struct list_t* head);
struct list_t* list_next(struct list_iterator_t* list_iterator);
struct list_t* list_prev(struct list_iterator_t* list_iterator);
void* list_payload_next(struct list_iterator_t* list_iterator);
void* list_payload_prev(struct list_iterator_t* list_iterator);
int list_add(struct list_t** head, void* payload);
void list_del(struct list_t** head, struct list_t* todel, void (*payload_free)(void*));
void list_free(struct list_t** head, void (*payload_free)(void*));

#endif

